#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/6/9 16:14
# @Author : linjinting
# @Project : custom_protocol
# @File : UI_config.py
# @Software: PyCharm

from unit.config import get_config


# def reload():
#     return get_config()


def config_ui(self):
    # print(mysql_config, recv_config, send_config)
    config = get_config()
    if not config:
        return
    config_mysql_ui(self, config)
    config_recv_ui(self, config)
    config_send_ui(self, config)


def config_mysql_ui(self, config):
    self.lineEdit_host_db.setText(config.get('mysql').host)
    self.lineEdit_port_db.setText(config.get('mysql').port)
    self.lineEdit_user.setText(config.get('mysql').user)
    self.lineEdit_password.setText(config.get('mysql').passwd)
    self.lineEdit_db.setText(config.get('mysql').db)
    self.lineEdit_charset.setText(config.get('mysql').charset)


def config_recv_ui(self, config):
    self.lineEdit_ip_recv.setText(config.get('recv').ip)
    self.lineEdit_port_recv.setText(config.get('recv').port)


def config_send_ui(self, config):
    self.lineEdit_ip_send.setText(config.get('send').ip)
    self.lineEdit_port_send.setText(config.get('send').port)
